import Service from "../utils/request";

interface queryUserList {
  pageNo: number;
  pageSize: number;
}

interface ICreatUser {
  id: string;
  username?: string;
  password?: string;
}

// 创建用户
export const creatUser = (data: ICreatUser) => {
  return Service({
    url: "/api/user",
    data,
    method: "post",
  });
};

// 编辑用户
export const editUser = ({ id, data }: any) => {
  return Service({
    url: "/api/user",
    params: { id: id },
    data,
    method: "patch",
  });
};

// 获取用户列表
export const getUserList = (data: queryUserList) => {
  return Service({
    url: "/api/user/getUserList",
    method: "post",
    data,
  });
};

// 删除用户
export const deleteUser = (id: string) => {
  return Service({
    url: "/api/user",
    params: { id: id },
    method: "delete",
  });
};
